//
//  MONavigationController.m
//  01,我的微博 (环境配置)
//
//  Created by user on 16/3/6.
//  Copyright © 2016年 son. All rights reserved.
//

#import "MONavigationController.h"
#import "UIBarButtonItem+item.h"
#import "MOTabBarController.h"
#import "MOTabBar.h"

@interface MONavigationController ()<UINavigationControllerDelegate>

@property (nonatomic,strong) id popDelegate;

@end

@implementation MONavigationController

- (void)viewDidLoad {
    [super viewDidLoad];
    

    //清空返回滑动手势
    self.interactivePopGestureRecognizer.delegate = nil;
    self.delegate = self;//滑动返回代理
    
    //设置全局导航栏的颜色,字体
    self.navigationBar.barTintColor = UnifiedColor;
    self.navigationBar.barStyle = UIBarStyleBlackTranslucent;
    [self.navigationBar setTintColor:[UIColor whiteColor]];

    
}

//控制器转调完成后调用//滑动返回
-(void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    
    if ((viewController = self.viewControllers[0])) {
        self.interactivePopGestureRecognizer.delegate = _popDelegate;
    }else{
        self.interactivePopGestureRecognizer.delegate = nil;
    }
}


-(void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    
    
    if (self.viewControllers.count ) {
        viewController.hidesBottomBarWhenPushed = YES;
        //左
    }
    [super pushViewController:viewController animated:animated];
}

// 删除系统自带的tabBarButton
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    UITabBarController *tabBarVc = (UITabBarController *)[UIApplication sharedApplication].keyWindow.rootViewController;
    
    // 删除系统自带的tabBarButton
    for (UIView *tabBarButton in tabBarVc.tabBar.subviews) {
        if (![tabBarButton isKindOfClass:[MOTabBar class]]) {
            [tabBarButton removeFromSuperview];
        }
    }
    
}


@end
